package com.wcll.www;
import java.util.*;
import java.sql.*;
public class CorrBean {
	private int id;
	private String name;
	private String password;
	private String areaprovince;
	private String areacity;
	private String areacounty;
	private String sysnopsis;
	private String phone;
	private String email;
	private java.util.Date createtime;
	private final int PAGE_ROWS = 20;
	private static Connection con=null;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getAreaprovince() {
		return areaprovince;
	}
	public void setAreaprovince(String areaprovince) {
		this.areaprovince = areaprovince;
	}
	public String getAreacity() {
		return areacity;
	}
	public void setAreacity(String areacity) {
		this.areacity = areacity;
	}
	public String getAreacounty() {
		return areacounty;
	}
	public void setAreacounty(String areacounty) {
		this.areacounty = areacounty;
	}
	public String getSysnopsis() {
		return sysnopsis;
	}
	public void setSysnopsis(String sysnopsis) {
		this.sysnopsis = sysnopsis;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public java.util.Date getCreatetime() {
		return createtime;
	}
	public void setCreatetime(java.util.Date createtime) {
		this.createtime = createtime;
	}
	public static Connection getCon() throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql:jdbc:Driver");
		con = DriverManager.getConnection("jdbc:mysql://localhost/jobs?useUnicode=true&characterEncoding=UTF8","root","");
		return con;
	}
	public static void setCon(Connection con) {
		CorrBean.con = con;
	}
	public ArrayList<CorrBean> getCorr(int currage){
		ArrayList<CorrBean> ab = new ArrayList<CorrBean>();
		int n = (currage-1)*this.PAGE_ROWS;
		try{
			con = CorrBean.getCon();
			Statement st = con.createStatement();
			ResultSet rs = st.executeQuery("select * from job_corporation");
			while(rs.next()){
			CorrBean a = new CorrBean();
			/*a.setId(rs.getInt("id"));*/
			a.setName("sdfsdfds");
			/*a.setPassword(rs.getString("cor_password"));
			a.setAreaprovince(rs.getString("cor_areaprovince"));
			a.setAreacity(rs.getString("cor_areacity"));
			a.setAreacounty(rs.getString("cor_areacounty"));
			a.setSysnopsis(rs.getString("cor_sysnopsis"));
			a.setPhone(rs.getString("cor_phone"));
			a.setEmail(rs.getString("cor_email"));
			a.setCreatetime(new java.util.Date(rs.getDate("create_time").getTime()));*/
			ab.add(a);
			}
			rs.close();
			st.close();
		}catch(Exception e){}
		return ab;
	}
	public boolean deleCorr(int id){
		boolean flags = false;
		try{
			con = CorrBean.getCon();
			Statement st = con.createStatement();
			st.execute("delete from job_corportion where id="+id);
			if(st.getUpdateCount()==1){
				flags = true;
			}
		}catch(Exception e){}
		return flags;
	}
	public int getCounts(){
		int pages = 0;
		double totals;
		
		try{
			con = GenBean.getCon();
			Statement st = con.createStatement();
			ResultSet rs = st.executeQuery("select count(*) as a from job_corportion");
			while(rs.next()){
				totals = (double)rs.getInt("a");
				pages = (int)Math.ceil(totals/this.PAGE_ROWS);
			}
		}catch(Exception e){}
		return pages;
	}
}
